<?php class import_temp extends Model {

    function __construct()
    {
        parent::__construct();
    }
      
    function truncate(){
    	return $this->db->truncate('import_temp');
    }
    
    
    function insert($array){
       if($array['temp_2']=='empty'){
         return true;
       }
       $re = $this->select($array);
       if(count($re)==0){
         $array['count']=1;
         $result = $this->db->insert('import_temp',$array);
       }else{
         $c['count'] = $re[0]->count+1;
         $result = $this->update($re[0]->id,$c);
       }
       
       if($result){
         return $result;
       }else{
         return false;
       }
    }
    
    function update($id,$a){
       $result = $this->db->update('import_temp',$a,array('id'=>$id));
       return $result;
    }
   
    function select($array=array()){
      if(count($array)!=0){
       unset($array['temp_1']);
       $this->db->where($array);
      }
       $query = $this->db->get('import_temp');       
       $result = $query->result();      
       return $result;
    }
    
    
    
    function del($id){
       $result = $this->db->delete('version',array('version_id'=>$id));
       return $result;
    }
}